package presentation;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

public class PoissonMainFrame extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	//Gestion de la barre de menu
	private JMenu menuFichier;
	private JMenuItem menuQuitter;
	private JMenu menuAide;
	private JMenuItem menuAPropos;
	private JMenuBar menuFinal;
	
	
	
	private JMenuBar initialiserMenus(){
		menuFichier = new JMenu("Fichier");
		menuQuitter = new JMenuItem("Quitter");
		menuFichier.add(menuQuitter);

		menuAide = new JMenu("Aide");
		menuAPropos = new JMenuItem("A Propos");
		menuAide.add(menuAPropos);

		menuFinal = new JMenuBar();
		menuFinal.add(menuFichier);
		menuFinal.add(menuAide);

		menuQuitter.addActionListener(new MenuListener());
		menuAPropos.addActionListener(new MenuListener());

		return menuFinal;
	}
	
	public PoissonMainFrame() {
		// La barre de menu
		JMenuBar mb = initialiserMenus();
		PanelConteneur jpC = new PanelConteneur();
		this.setJMenuBar(mb);
		this.add(jpC);
		this.setSize(getPreferredSize());
		this.setLocation(NORMAL, NORMAL);
		
	}
	
	class MenuListener implements ActionListener{
		@Override
		public void actionPerformed(ActionEvent ae) {
			// TODO Auto-generated method stub
			if(ae.getSource() == menuQuitter){
				System.exit(0);
			}
			
			if(ae.getSource() == menuAPropos){
				JOptionPane.showMessageDialog(null, "Application réalise par :\n  BAROUTY Loïc\n  FRAISSE Pierre\n  MAGLOIRE Alexandre\n  MARTINEAU Amaury\n  TEIXEIRA Thibaut\n  " +
						"						VIVIER Romain\n \n");
			}			
		}		
	}
}
